<?php

if (!function_exists('categories')) {
	function categories($slug) {
		if (!$slug) {
			return null;
		}

		if ($slug == 'root') {
			return (new \Boosen\Admin\Contents\Models\Category())->getItemsTree(0);
		}
		$cate = \Boosen\Admin\Contents\Models\Category::where('slug', $slug)->first();
		if (!$cate) {
			return null;
		}

		return $cate->getItemsTree($cate->id);
	}
}


if (!function_exists('b_post')) {
	function b_post($slug) {
		if (!$slug) {
			return null;
		}

		return (new \Boosen\Admin\Contents\Models\Post())->where('slug', $slug)->find();
	}
}

if (!function_exists('b_page')) {
	function b_page($slug) {
		if (!$slug) {
			return null;
		}

		return (new \Boosen\Admin\Contents\Models\Page())->where('slug', $slug)->find();
	}
}